package com.example.expandablelistview.fragmentdialog;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

import com.example.expandablelistview.R;

public class PopUpWindowEx extends Activity {
	PopupWindow popup;
	View popupView;
	LinearLayout linear;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialogex);
		linear = (LinearLayout) findViewById(R.id.popupwindowlinear);
		popupView = View.inflate(this, R.layout.popupview, null);
		popup = new PopupWindow(popupView, 200, 150, true);
		final Button btnshow = (Button) findViewById(R.id.commactivity_btn);
		btnshow.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				// popup.showAtLocation(linear,Gravity.NO_GRAVITY,50,100); //
				// 지정한 좌표에 놓기
				// popup.showAtLocation(linear,Gravity.CENTER,0,0); // 가운데 놓기
				// popup.showAtLocation(linear,Gravity.CENTER,50,80); // 가운데 +
				// 50, 80에 놓기
				// popup.showAtLocation(linear,Gravity.NO_GRAVITY,800,1200); //
				// 화면 벗어나기
				// popup.showAtLocation(linear,Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM,0,0);//수평중앙,
				// 수직바닥
				popup.showAtLocation(linear, Gravity.CENTER_HORIZONTAL
						| Gravity.BOTTOM, 50, 50);
				popup.setAnimationStyle(-1);
				popup.showAsDropDown(btnshow);
			}
		});
		popupView.findViewById(R.id.btnclose).setOnClickListener(
				new OnClickListener() {
					public void onClick(View v) {
						popup.dismiss();
					}
				});
	}
}
